//
//  TXPRadioDetailView.m
//  StayAwhile
//
//  Created by dllo on 16/1/29.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TXPRadioDetailView.h"
#import <Masonry.h>
#import "TXPRadioModel.h"
@interface TXPRadioDetailView ()

@property (nonatomic,strong)UIImageView *covering;
@property (nonatomic,strong)UIImageView *icon;
@property (nonatomic,strong)UILabel *title;
@property (nonatomic,strong)UILabel *desc;
@property (nonatomic,strong)UILabel *musicvisitnum;
@property (nonatomic,strong)UIImageView *tagImg;
@end

@implementation TXPRadioDetailView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    
    if ([super initWithFrame:frame]) {
        
        [self createSubView];
    }
    
    return self;
}
- (void)createSubView{
    
    self.covering = [[UIImageView alloc] init];
    [self addSubview:self.covering];
    [self.covering mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(0, 0, 140, 0));
        
    }];
    
    self.icon = [[UIImageView alloc] init];
    self.icon.layer.cornerRadius = 20;
    // self.icon.layer.borderWidth = 1;
    self.icon.layer.masksToBounds = YES;
    [self addSubview:self.icon];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.mas_left).offset(20);
        make.right.mas_equalTo(self.mas_right).offset(-(WIDTH-60));
        make.top.mas_equalTo(self.covering.mas_bottom).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-80);
        
    }];
    
    self.title = [[UILabel alloc] init];
    self.title.text = @"半岛玫瑰";
    [self addSubview:self.title];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).offset(7);
        make.right.mas_equalTo(self.mas_right).offset(-100);
        make.top.mas_equalTo(self.icon.mas_top).offset(12);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-80);
    }];
    
    self.desc = [[UILabel alloc] init];
    self.desc.text = @"渗入灵魂的交涉";
    self.desc.font = [UIFont systemFontOfSize:19];
    [self addSubview:self.desc];
    [self.desc mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.mas_left).offset(20);
        make.right.mas_equalTo(self.mas_right).offset(-100);
        make.top.mas_equalTo(self.icon.mas_bottom).offset(30);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-40);
        
    }];
    
    self.tagImg = [[UIImageView alloc] init];
    self.tagImg.image = [UIImage imageNamed:@"listen"];
    [self addSubview:self.tagImg];
    [self.tagImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.icon.mas_right).offset(230);
        make.right.mas_equalTo(self.mas_right).offset(-100);
        make.top.mas_equalTo(self.covering.mas_bottom).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-100);
        
    }];
    
    self.musicvisitnum = [[UILabel alloc] init];
    self.musicvisitnum.font = [UIFont systemFontOfSize:16];
    self.musicvisitnum.text = @"12345678";
    self.musicvisitnum.textColor = [UIColor colorWithRed:170 / 255.0 green:170 / 255.0 blue:170 / 255.0 alpha:1.0];
    [self addSubview:self.musicvisitnum];
    [self.musicvisitnum mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.tagImg.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.top.mas_equalTo(self.covering.mas_bottom).offset(20);
        make.bottom.mas_equalTo(self.mas_bottom).offset(-100);
        
    }];
    
}
- (void)setModelArray:(NSMutableArray *)modelArray
{
    
    _modelArray = modelArray;
    
    for (TXPRadioModel *model in _modelArray) {
        [self.covering sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:[UIImage imageNamed:@"c3b08068f41ac81243561c5d387ea55c"]];
        self.title.text = model.title;
        [self.icon sd_setImageWithURL:[NSURL URLWithString:model.infoModel.icon] placeholderImage:[UIImage imageNamed:@"c3b08068f41ac81243561c5d387ea55c"]];
        self.musicvisitnum.text = [NSString stringWithFormat:@"%@",model.musicvisitnum];
    }
}

@end
